package db;

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import db.*;

public class DelUser extends HttpServlet {
	public void doPost(HttpServletRequest request,HttpServletResponse response)
										throws ServletException, IOException {
		response.setContentType("text/html");
		PrintWriter out = response.getWriter();
		DatabaseConnector DBConnect = new DatabaseConnector(DatabaseConnector.getDatabaseType());

		out.println("<html><head>");
		out.println("<title>Delete User</title></head><body bgcolor=FFFFFF>");

		DBConnect.deleteSQL("User_Roles","username",request.getParameter("username"));
		DBConnect.deleteSQL("User_Info","username",request.getParameter("username"));
		DBConnect.deleteSQL("Users","username",request.getParameter("username"));

		out.println("<p>User "+request.getParameter("username")+" was successfully removed from the Database.</p>");
		out.println("<form method=\"post\" action=\"ListUsers\">");
		out.println("<input type=\"submit\" value=\"Back to User List\" /></form>");

		out.println("</body></html>");
        out.close();
	}

	public void doGet(HttpServletRequest request, HttpServletResponse response)
	    throws ServletException, IOException {
			doPost(request, response);
	}
}